import java.io.PrintStream;

/**
 * Created by thoughtworker on 1/16/14.
 */
public class FindPlayerAction implements MenuAction {

    PrintStream printStream;
    Catalog catalog;
    InputReader inputReader;

    public FindPlayerAction(PrintStream printStream, InputReader inputReader, Catalog catalog){
        this.printStream = printStream;
        this.catalog = catalog;
        this.inputReader = inputReader;
    }

    public void performAction() {
        printStream.println("Please enter in the name of requested player");
        String requestedName = inputReader.getInput();
        printStream.println("Please enter in the number of requested player");
        String requestedNumber = inputReader.getInput();

        Player foundPlayer = catalog.search(requestedName, Integer.parseInt(requestedNumber));

        if (foundPlayer != null)
            printStream.println("Successful! Your player is " + foundPlayer.toString());
        else
            printStream.println("Unsuccessful search, please try again!");
    }

    public String toString() {
        return "find player";
    }
}
